package com.mybatis.main;

import com.mybatis.entity.Employee;
import com.mybatis.entity.Role;
import com.mybatis.mapper.EmployeeMapper;
import com.mybatis.mapper.RoleMapper;
import com.mybatis.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;

/**
 * @author qinjiasheng
 */
public class Chapter5Main {
    public static void main(String[] args) {
        Logger logger = Logger.getLogger(Chapter5Main.class);
        SqlSession sqlSession = null;
        try {
            sqlSession = SqlSessionFactoryUtils.openSqlSession();
//            EmployeeMapper employeeMapper = sqlSession.getMapper(EmployeeMapper.class);
//            Employee employee = employeeMapper.getEmployee(1L);
//            logger.info(employee.getBirthday());
            RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class);
            Role role = roleMapper.getRole(1L);
            logger.info("再次测试获取角色");
            Role role2 = roleMapper.getRole(1L);
        } finally {
            if (sqlSession != null) {
                sqlSession.close();
            }
        }

    }
}
